package com.stone.boot.file.config;

import com.aliyun.oss.OSSClient;
import com.stone.boot.file.config.property.AliyunOssBaseProperty;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 用于配置OSS的连接客户端OSSClient
 *
 * @author Mr_wenpan@163.com 2021/8/19 2:31 下午
 */
@EnableConfigurationProperties({AliyunOssBaseProperty.class})
@Configuration
public class OssConfig {

    @Value("${aliyun.oss.endpoint}")
    private String aliyunOssEndpoint;
    @Value("${aliyun.oss.accessKeyId}")
    private String aliyunOssAccesskeyid;
    @Value("${aliyun.oss.accessKeySecret}")
    private String aliyunOssAccesskeySecret;

    @Bean
    public OSSClient ossClient() {
        return new OSSClient(aliyunOssEndpoint, aliyunOssAccesskeyid, aliyunOssAccesskeySecret);
    }
}